In [1]:
# -*- coding: utf-8 -*-
# !/usr/bin/python
# Cross Wavelet Analysis (CWA) based on Maraun and Kurths(2004).
# http://www.nonlin-processes-geophys.net/11/505/2004/npg-11-505-2004.pdf
# author: Mabel Calim Costa
# INPE
# 23/01/2013
# reviewed --- 02/03/2018
"""
Created on Mon Jun 17 2013
@author: Mabel Calim Costa
"""
import numpy as np
import pylab
from pylab import *
import matplotlib.pyplot as plt
import cmath
import pandas as pd
In [2]:
# using the example : example_python3.6.ipynb
import numpy as np
from pylab import *
import waipy
z = np.linspace(0,2048,2048)
x = np.sin(50*np.pi*z)
data_norm_x = waipy.normalize(x)
result_x = waipy.cwt(data_norm_x, 1, 1, 0.125, 2, 4/0.125, 0.72, 6,mother='Morlet',name='x')
waipy.wavelet_plot('x', z, x, 0.03125, result_x)
In [3]:
#let's create another artificial signal to compare with that!
#y = np.cos(50*np.pi*z) # signal out of phase from x
noise = np.sin(7*np.pi*z/3)+np.cos(2*np.pi*z/3)
y = np.sin(30*np.pi*z/3)+noise #out of phase signal compared to x + noise
data_norm_y = waipy.normalize(y)
result_y = waipy.cwt(data_norm_y, 1, 1, 0.125, 2, 4/0.125, 0.72, 6,mother='Morlet',name='x')
waipy.wavelet_plot('y', z, y, 0.03125, result_y)
In [8]:
cross_power, coherence, phase_angle = cross_wavelet(result_x['wave'],result_y['wave'])
plot_cross('signals', cross_power, phase_angle, z, result_x, result_y)
#Arrows indicate in phase when pointing to the right and out of phase when pointing left.
In [9]:
cross_power, coherence, phase_angle = cross_wavelet(result_x['wave'],result_y['wave'])
plot_cohere('signals',coherence,z,result_x, result_y)
In [305]:
cross_power, coherence, phase_angle = cross_wavelet(result_x['wave'],result_x['wave'])
plot_cohere('signals',coherence,z,result_x, result_x)
In [ ]: